package org.example;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-10-29
 * 21:38
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=0;
        if(a>b){
            int tmp=b;
            b=a;
            a=tmp;
             c=gcd(a,b);
        }else{
             c=gcd(a,b);
        }
        System.out.println(c);
    }
    static int gcd(int a,int b){//a小b大
        while(a!=0){
            int tmp=a;
            a=b%a;
            b=tmp;
        }
        return b;
    }
}
